package com.df.tv.launcher.util;

import com.df.tv.launcher.params.ComParams;
import com.lidroid.xutils.http.RequestParams;
import com.telecom.tv189.comlib.net.HttpComParams;
import com.telecom.tv189.comlib.net.XHttpParams;
import com.telecom.tv189.comlib.util.DateUtil;

public class XHttpParamsUtil {

    private static XHttpParamsUtil sUtil;

    private XHttpParamsUtil() {}

    public static XHttpParamsUtil getInstance() {
        if (sUtil == null)
            sUtil = new XHttpParamsUtil();
        return sUtil;
    }

    public RequestParams getIndex(String token, String path) {
        XHttpParams params = new XHttpParams();
        params.addAC(HttpComParams.AC.INDEX);
        params.addFUNC(HttpComParams.FUNC.INDEX);

        params.addQueryStringParam(HttpComParams.KEY.CLIENT_TYPE, ComParams.CLIENT_TYPE);

        params.addQueryStringParam(HttpComParams.KEY.PCODE, ComParams.PCODE);
        params.addQueryStringParam("lan", "1");
        params.addQueryStringParam("token", token);
        params.addQueryStringParam("path", path);
        params.addQueryStringParam("type", "cpsPath");
        return params.toXRequestParams();
    }

    public RequestParams tmsGetFile(String tmssn, int tmsfileType) {
        XHttpParams params = new XHttpParams();
        params.addAC(HttpComParams.AC.TMS);
        params.addFUNC(HttpComParams.FUNC.TMS_GET_FILE);

        params.addQueryStringParam("tmssn", tmssn);
        params.addQueryStringParam("tmsfileType", tmsfileType + "");
        params.addQueryStringParam("tmstime", DateUtil.getCurrTimeStamp());
        return params.toXRequestParams();
    }

    public RequestParams tmsUpdateLog(String token, int tmsaction, int tmscode, String tmsmsg) {
        XHttpParams params = new XHttpParams();
        params.addAC(HttpComParams.AC.TMS);
        params.addFUNC(HttpComParams.FUNC.TMS_UPDATE_LOG);

        params.addQueryStringParam("token", token);
        params.addQueryStringParam("tmsaction", tmsaction + "");
        params.addQueryStringParam("tmscode", tmscode + "");
        params.addQueryStringParam("tmstime", DateUtil.getCurrTimeStamp());
        params.setPostBody("tmsmsg=" + tmsmsg);
        return params.toXRequestParams();
    }

    public RequestParams playInfo(String token, String contentId) {
        XHttpParams params = new XHttpParams();
        params.addAC(HttpComParams.AC.PLAY);
        params.addFUNC(HttpComParams.FUNC.PLAYURL);

        params.addQueryStringParam(HttpComParams.KEY.CLIENT_TYPE, ComParams.CLIENT_TYPE);
        params.addQueryStringParam(HttpComParams.KEY.TOKEN, token);
        params.addQueryStringParam(HttpComParams.KEY.CONTENT_ID, contentId);
        params.addQueryStringParam(HttpComParams.KEY.PCODE, ComParams.PCODE);
        return params.toXRequestParams();
    }
}
